<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/template/template.xhtml"
>
	<ui:define name="conteudo">
	<div class="page-header">
		<ol class="breadcrumb breadcrumb-page">
			<li>
				<h:outputLink>
					<h:outputText value="#{mensagens['display.voce.esta.em']}" />
				</h:outputLink>
			</li>
			<li>
				<h:outputText value="#{mensagens['display.gerencia.sistema']}" />
			</li>
			<li>
				<h:outputText value="#{mensagens['display.consultar.usuario']}" />
			</li>
			<li>
				<h:outputText value="#{mensagens['display.lista.usuarios']}" />
			</li>
			<li>
				<h:outputText value="#{mensagens['display.detalhar']}" />
			</li>
			<li class="active">
				<h:outputText value="#{mensagens['display.alterar.usuario']}" />
			</li>
		</ol>
		<h:messages id="mensagens"  globalOnly="true" fatalClass="alert alert-danger alert-dark" errorClass="alert alert-warning alert-dark" infoClass="alert alert-info alert-dark" warnClass="alert alert-dark"/>
	</div>
	<div id="content" class="content">
		<div class="row">
			<div class="col-md-12">
				<h:form id="form" prependId="false" styleClass="form-horizontal">
				<div class="panel">
					<div class="panel-heading">
						<span class="panel-title"><h:outputText value="#{mensagens['display.cadastrar.usuario']}" /> </span>
					</div>
					<div class="panel-body">
						<div class="form-group">
							<label class="control-label col-sm-2"><h:outputText value="#{mensagens['display.perfil']}:"  /></label>
							<div class="col-sm-2">
								<h:selectOneMenu id="perfil"  value="#{alterarBean.usuario.perfil}" styleClass="form-control" required="true" requiredMessage="#{mensagens['display.selecione.tipo.perfil']}">
									<f:selectItem itemLabel="#{mensagens['display.selecione']}" itemValue="" />
									<f:selectItem itemLabel="#{mensagens['display.aluno']}" itemValue="1" />
									<f:selectItem itemLabel="#{mensagens['display.professor']}" itemValue="2" />
									<f:selectItem itemLabel="#{mensagens['display.coordenador']}" itemValue="3" />
									<f:ajax event="change" render="btnGerarMatricula"/>
								</h:selectOneMenu>
								<h:message  for="perfil" errorClass="msg error"/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">
								<h:outputText value="#{mensagens['display.nome']}:" />
							</label>
							<div class="col-sm-4">
								<h:inputText id="nome"  value="#{alterarBean.usuario.nome}" maxlength="58" styleClass="form-control x4" autocomplete="off" required="true" requiredMessage="#{mensagens['display.campo.obrigatorio']}"/>
								<h:message for="nome" errorClass="msg error"/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">
								<h:outputText value="#{mensagens['display.matricula']}:" />	
							</label>
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<h:commandButton id="btnGerarMatricula" styleClass="btn btn-primary"  value="#{mensagens['display.gerar']}" action="#" disabled="#{alterarBean.usuario.perfil == 0}" immediate="true">
											<f:ajax event="click" render="matricula" listener="#{alterarBean.gerarMatricula()}"/>
										</h:commandButton>
									</div>
									<h:inputText id="matricula" value="#{alterarBean.usuario.matricula}" readonly="true" maxlength="11"  styleClass="form-control" autocomplete="off" required="true" requiredMessage="#{mensagens['display.campo.obrigatorio']}"/>
								</div>
								<h:message for="matricula" errorClass="msg error"/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">
								<h:outputText value="#{mensagens['display.cpf']}:" />	
							</label>
							<div class="col-sm-2">
								<h:inputText id="cpf" value="#{alterarBean.usuario.cpf}" maxlength="11"  styleClass="form-control cpf" autocomplete="off" required="true" requiredMessage="#{mensagens['display.campo.obrigatorio']}"/>
								<h:message for="cpf" errorClass="msg error"/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">
								<h:outputText value="#{mensagens['display.email']}:" />
							</label>
							<div class="col-sm-4">
								<h:inputText id="email" validatorMessage="#{mensagens['display.email.invalido']}" required="true" requiredMessage="#{mensagens['display.campo.obrigatorio']}" value="#{alterarBean.usuario.email}" maxlength="50" styleClass="form-control"  autocomplete="off">
									<f:validateRegex  for="email" pattern="#{alterarBean.emailPattern}"/>
								</h:inputText>
								<h:message for="email" errorClass="msg error"/>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-10">
								<div class="checkbox">
									<label>
										<h:outputText value="#{mensagens['display.inativo']}"/>
										<h:selectBooleanCheckbox id="inativo" value="#{alterarBean.inativo}" />
									</label>
									<h:message for="inativo" errorClass="msg error"/>
								</div>
							</div>
						</div>
					</div>
					<div class="panel-footer">
						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-10">
								<h:commandButton value="#{mensagens['display.alterar']}" styleClass="btn btn-primary btn-xs" action="#{alterarBean.alterarUsuario()}" />
							</div>
						</div>
					</div>
					</div>	
				</h:form>
				</div>
			</div>
		</div>
	</ui:define>
</ui:composition>